package com.zd.controller;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zd.error.BaseException;
import com.zd.error.Code500Exception;
import com.zd.vo.BaseBody;

public class BaseController {
	@ExceptionHandler
	@ResponseBody
	public BaseBody baseException(BaseException e){
		BaseBody response = new BaseBody();
		response.setCode(e.getCode());
		response.setMsg(e.getMsg());
		return response;
	}
	
	@ExceptionHandler
	@ResponseBody
	public BaseBody Exception (Exception e){
		e.printStackTrace();
		BaseBody response =  baseException(new Code500Exception());
		return response;
		
	}
}
